﻿//===============================================================================
// TREASURY MANAGMENT INFORMATION SYSTEMS 
// DB HELPER CLASS HELPER CLASSES FOR DATABASES
//===============================================================================
// Copyright © TIMS GROUP. 2008
//===============================================================================

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace APPLICATION.DataAccess
{
    class dbHelper
    {

        /// <summary>
        /// Gets a value indicating whether the DataSet has changes, including new, deleted, or modified rows.
        /// </summary>
        /// <param name="dataSet"></param>
        /// <returns>true if the DataSet has changes; otherwise false.</returns>
        public bool HasDatasetChanges(DataSet dataSet)
        {
            if (dataSet == null) return false;
            for (int table = 0; table < dataSet.Tables.Count; table++)
            {
                for (int row = 0; row < dataSet.Tables[table].Rows.Count; row++)
                {
                    for (int col = 0; col < dataSet.Tables[table].Columns.Count; col++)
                    {
                        if (dataSet.Tables[table].Rows[row].RowState == DataRowState.Added) return true;
                        if (!dataSet.Tables[table].Rows[row][col, DataRowVersion.Original].Equals(dataSet.Tables[table].Rows[row][col, DataRowVersion.Current])) return true;
                    }
                }
            }
            return false;
        }
    }
}
